package com.example.shop_2212.room

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.OnConflictStrategy.REPLACE
import androidx.room.Query
import androidx.room.Update
import com.example.base.entity.LoginEntity

@Dao
interface UserDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(loginEntity: LoginEntity)

    @Update
    fun update(loginEntity: LoginEntity)

    @Delete
    fun delete(loginEntity: LoginEntity)

    @Query("select * from user where uid = :uid")
    fun query(uid:Int):MutableList<LoginEntity>//在项目初期，可能会出现数据返回多条的情况，防止崩溃，返回集合
    @Query("select * from user order by uid desc")
    fun queryOrder():MutableList<LoginEntity>//查询所有用户，按uid倒序排序 （desc）
    @Query("select * from user where nikeName like :name")
    fun queryByName(name:String):MutableList<LoginEntity>//查询名称包含name的所有用户
}